package fr.expdev.bndd.data.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

public abstract class ModelSQLite {

	/**
	 * Base de données
	 */
	protected final BNDDSQLite sqlite;
	
	/**
	 * Connexion à la bdd
	 */
	protected SQLiteDatabase db;

	public ModelSQLite(Context context) {
		sqlite = new BNDDSQLite(context);
	}
	
	/**
	 * Ouverture de la base
	 * @param writable True pour ouvrir en écriture
	 */
	public void open(boolean writable) {
		if (writable) {
			db = sqlite.getWritableDatabase();
		} else {
			db = sqlite.getReadableDatabase();
		}
	}

	/**
	 * Fermeture de la base
	 */
	public void close() {
		db.close();
	}

}
